package ldh.im.fxgui.controller;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import ldh.im.fxbase.pojo.DbMessage;

import java.net.URL;
import java.util.ResourceBundle;

public class UserMessageController implements Initializable {

    @FXML private ImageView userHeadImageView;
    @FXML private Label userNameLabel;
    @FXML private Label userMessageTextArea;

    public void setData(DbMessage message) {
        if (message instanceof DbMessage) {
            DbMessage textMessage = (DbMessage) message;
            userNameLabel.setText(textMessage.getFromUser().getUserName());
            userMessageTextArea.setText(textMessage.getContent());
            Image image = new Image(textMessage.getFromUser().getHeadImg());
            userHeadImageView.setImage(image);
        }
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {

    }
}
